package com.mach.platform.sprider.dev;

public class IntNum {

	private final byte[] buf;
	private Integer value;

	public IntNum(Integer i) {
		this.value = i;
		this.buf = intToBytes(i);
	}
	
	public void addOne() {
		this.value = this.value + 1;
	}

	public byte h2() {
		return this.buf[2];
	}
	public byte l2() {
		return this.buf[3];
	}

	public byte hh2() {
		return (byte)(this.value / 256);
	}
	public byte ll2() {
		return (byte)(this.value % 256);
	}
	
	public byte rh2() {
		return (byte)(this.value % 256);
	}
	public byte rl2() {
		return (byte)(this.value / 256);
	}

	public byte h3() {
		return (byte)(this.value & Integer.MAX_VALUE-255);
	}
	public byte l3() {
		return (byte)(this.value & 255);
	}


	public static void main(String args[]){
		IntNum i = new IntNum(-1);

		System.out.println(i.h3());
		System.out.println(i.l3());

		Integer a = 1;

		UU.printData(intToBytes(256));

	}
	public static byte[] intToBytes(int i) {
		byte[] targets = new byte[4];
		targets[3] = (byte) (i & 0xFF);
		targets[2] = (byte) (i >> 8 & 0xFF);
		targets[1] = (byte) (i >> 16 & 0xFF);
		targets[0] = (byte) (i >> 24 & 0xFF);
		return targets;
	}
	public static byte[] shortToBytes(int i) {
		byte[] targets = new byte[2];
		targets[1] = (byte) (i & 0xFF);
		targets[0] = (byte) (i >> 8 & 0xFF);
		return targets;
	}
}
